//
//  AFHTTPRequestOperationManager+Util.m
//  oschina_song
//
//  Created by song on 16/1/26.
//  Copyright © 2016年 song. All rights reserved.
//

#import "AFHTTPRequestOperationManager+Util.h"
#import "AFOnoResponseSerializer.h"

@implementation AFHTTPRequestOperationManager (Util)

+(instancetype)OSCManger
{
    AFHTTPRequestOperationManager *manger =[AFHTTPRequestOperationManager manager];
    manger.responseSerializer  = [AFOnoResponseSerializer XMLResponseSerializer];
    manger.responseSerializer.acceptableContentTypes = [manger.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
    NSLog(@"%@",[self generateUserAgent]);
    [manger.requestSerializer setValue:[self generateUserAgent] forHTTPHeaderField:@"User-Agent"];
    return manger;
}

+ (NSString *)generateUserAgent
{
    NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
    NSString *IDFV = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    
    return [NSString stringWithFormat:@"OSChina.NET/%@/%@/%@/%@/%@", appVersion,
            [UIDevice currentDevice].systemName,
            [UIDevice currentDevice].systemVersion,
            [UIDevice currentDevice].model,
            IDFV];
}

@end
